﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XiDainChangAn.OA.EFDAL;
using XiDainChangAn.OA.IDAL;

namespace XiDainChangAn.OA.DALFactory
{
    public class DbSession:IDbSession
    {
        #region 简单工厂的再次包装 跨世纪
        //它有所有dal的实例
        public IUserInfoDal UserInfoDal
        {
            get { return AbstractDalFactory.GetUserInfoDal(); }
        }
        public IOrderInfoDal OrderInfoDal
        {
            get { return AbstractDalFactory.GetOrderInfoDal(); }
        }

        public IWF_InstanceDal WF_InstanceDal
        {
            get { return AbstractDalFactory.GetWF_InstanceDal(); }
        }

        public IWF_StepDal WF_StepDal
        {
            get { return AbstractDalFactory.GetWF_SetpDal(); }
        }

        public IWF_TempDal WF_TempDal
        {
            get { return AbstractDalFactory.GetWF_TempDal(); }
        }

        public IFileInfoDal FileInfoDal
        {
            get { return AbstractDalFactory.GetFileInfDal(); }
        }

        public IRoleInfoDal RoleInfoDal
        {
            get { return AbstractDalFactory.GetRoleInfoDal(); }
        }

        public IActionInfoDal ActionInfoDal
        {
            get { return AbstractDalFactory.GetActionInfoDal(); }
        }

        #endregion

        /// <summary>
        /// 拿到当前的EF的数据上下文，然后进行 把修改实体进行一个整体提交
        /// </summary>
        /// <returns></returns>
        public int SaveChange()
        {
            return DBContextFactory.GetCurrentDbContext().SaveChanges();
        }

    }
}
